#ifndef module_logFile_h
#define module_logFile_h//日志记录模块启用,防止重复定义
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <arpa/inet.h>  
#include <netinet/in.h> 
#include "parse.h"


typedef struct
{
    FILE *fp;//日志记录文件指针
    char *filename;
    char *mode;
}logFile;

typedef struct HttpResponse{
    int code;               // HTTP 状态码（200, 400, 404, 500...）
    const char* status;     // 状态文本（"OK", "Bad Request"...）
    const char* headers;    // 完整的 HTTP 响应头（含 \r\n\r\n）
} HttpResponse;

int logFile_init(logFile *log, const char *filename, char* mode);
char *messageGet(HttpResponse res, const char *client_ip, const char *method, const char *path, char* contentLength);
char *ErrorMessageGet(HttpResponse res,const char *client_ip,  pid_t pid);
int logFile_write(logFile *log, const char *message);
int logFile_close(logFile *log);
void access_log(HttpResponse res, struct sockaddr_in *cli_addr, Request* request, char* path, char* content_length);
void error_log(HttpResponse res, struct sockaddr_in *cli_addr);
extern HttpResponse resp[];
#endif
